package com.rftennis.web.filters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AuthorityFilter implements Filter {

 @Override
public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain)throws IOException, ServletException {
	HttpServletRequest req =(HttpServletRequest)servletrequest;
	HttpServletResponse resp=(HttpServletResponse)servletresponse;
	
	if(isLogin(req)) {
		filterchain.doFilter(req, resp);
	
		
	}else {
		resp.sendRedirect(req.getContextPath()+"/no-authority.jsp");
	}
}
 private boolean isLogin(HttpServletRequest req) {
	 return req.getSession().getAttribute("model")!=null;
 }
}
